{include file="header.html"}
<script type="text/javascript" src="index.php?act=jslang"></script>
<script src="{lib file=jquery.plugins/additional-methods.js}" charset="utf-8"></script>
<script type="text/javascript">
//<!CDATA[
$(function(){
    $('#store_form').validate({
        errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
        },
        success : function(label){
            label.addClass('right').text('OK!');
        },
        onkeyup    : false,
        rules : {
            store_no : {
                required : true,
                remote : {
                    url  : 'index.php?app=storeo2o&act=check_store_no',
                    type : 'get',
                    data : {
                        store_no : function(){
                            return $('#store_no').val();
                        },
                        id : '{$store.store_id}'
                    }
                }
            },
            store_floor: {
                required: true
            },
            store_name: {
                required : true,
            },
            tel: {
                isPhone: true
            },
            email:{
                email : true
            },
            qq:{
                isQQ : true
            }
        },
        messages : {
            store_no: {
                required: '店铺铺号不能为空',
                remote: '该店铺铺号已被占用'
            },
            store_floor: {
                required: '楼层不能为空'
            },
            store_name: {
                required: '店铺名称不能为空',
            },
            tel:{
                isPhone: '电话号码格式不正确'
            },
            email:{
                email : '邮箱格式不正确'
            },
            qq:{
                isQQ : 'qq格式不正确'
            }
        }
    });
});
//]]>
function add_sgcategory(id) {
    var sgcategory = $('.sgcategory_' + id).eq(0);
    $(".sgcategory_" + id + ":last").after(sgcategory.clone());
}
function add_uploadedfile(image_data)
{
    var newImg = '<tr id="' + image_data.image_id + '" class="tatr2"><input type="hidden" name="image_id[]" value="' + image_data.image_id + '" /><td><img width="100px" height="100px" src="' + SITE_URL + '/' + image_data.image_url + '" /></td><td><a href="javascript:insert_to(\'hot\',\'' + image_data.image_url + '\');">热卖图标</a> | <a href="javascript:insert_to(\'feature\',\'' + image_data.image_url + '\');">特色图标</a> | <a href="javascript:drop_uploadedfile(' + image_data.image_id + ');">{$lang.drop}</a></td></tr>';
    $('#thumbnails').prepend(newImg);
}
function drop_uploadedfile(image_id)
{
    if(!window.confirm("确定要删除此图片吗？")){
        return;
    }
    $.getJSON('index.php?app=storeo2o&act=drop_uploadedfile&image_id=' + image_id, function(result){
        if(result.done){
            $('#' + image_id).remove();
        }else{
            alert('drop_error');
        }
    });
}
function insert_to(type, image_url)
{
    var store_id = "{$store.store_id}";
    $.getJSON('index.php?app=storeo2o&act=insert_image&store_id=' + store_id + '&type=' + type + '&image_url=' + image_url, function(result){
        if(result.done){
            //编辑
            $('#tr_' + type + '_image').css("display", "block");
            $('#' + type).attr("src", SITE_URL + '/' + image_url);
        }else{
            //添加
            $("input[name="+type+"_image]").val(image_url);
            $('#tr_' + type + '_image').css("display", "block");
            $('#' + type).attr("src", SITE_URL + '/' + image_url);
        }
    });
}
</script>
{$build_upload}
<div id="rightTop">
  <p>店铺</p>
  <ul class="subnav">
    <li><a class="btn1" href="index.php?app=storeo2o">{$lang.manage}</a></li>
    {if $act eq "edit"}
    <li><span>{$lang.edit}</span></li>
    {else}
    <li><span>{$lang.add}</span></li>
    {/if}
  </ul>
</div>
<div class="info">
  <form method="post" enctype="multipart/form-data" id="store_form">
    <table class="infoTable">
      <tr>
        <th class="paddingT15">店铺铺号:</th>
        <td class="paddingT15 ">
            <input class="infoTableInput2" name="store_no" type="text" id="store_no" value="{$store.store_no|escape}" />
            <span style="color: gray">有多个铺号，请用英文","号分割开，如:1A301,1A302</span>
        </td>
      </tr>
      <!--{foreach from=$languages item=language}-->
      <!--{assign var="langid" value="$language.lang_id"}-->
      <tr>
        <th class="paddingT15">{$language.name}店铺名称:</th>
        <td class="paddingT15 "><input class="infoTableInput" name="store_name[{$langid}]" type="text" id="store_name_{$langid}" value="{$store.store_name.$langid|escape}" /></td>
      </tr>
      <!--{/foreach}-->
      <tr>
        <th class="paddingT15">联系人:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="owner_name" type="text" id="owner_name" value="{$store.owner_name|escape}" /></td>
      </tr>
      <tr>
        <th class="paddingT15"> 电话:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="tel" type="text" id="tel" value="{$store.tel}"/>        </td>
      </tr>
        <tr>
        <th class="paddingT15">QQ:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="qq" type="text" id="qq" value="{$store.qq}"/>        </td>
      </tr>
        <tr>
        <th class="paddingT15">邮箱:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="email" type="text" id="email" value="{$store.email}"/>        </td>
      </tr>
        <tr>
        <th class="paddingT15">微信号:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="weixin" type="text" id="weixin" value="{$store.weixin}"/>        </td>
      </tr>
        <tr>
        <th class="paddingT15">所在楼层:</th>
        <td class="paddingT15 ">
            <select name="store_floor">
                <option value="">请选择--</option>
                {html_options options=$floors selected=$store.store_floor}
            </select>
        </td>
      </tr>
        <tr>
        <th class="paddingT15">店铺进驻万菱时间:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="enter_time" type="text" id="enter_time" value="{$store.enter_time}"/>        </td>
      </tr>
        <tr>
        <th class="paddingT15">租赁年限:</th>
        <td class="paddingT15 "><input class="infoTableInput2" name="total_year" type="text" id="total_year" value="{$store.total_year|escape}"/>        </td>
      </tr>
      <!--{foreach from=$languages item=language}-->
      <!--{assign var="langid" value="$language.lang_id"}-->
        <tr>
        <th class="paddingT15">{$language.name}主营产品:</th>
        <td class="paddingT15 ">
            <input class="infoTableInput" name="products[{$langid}]" type="text" style="width: 800px;" id="products_{$langid}" value="{$store.products.$langid|escape}"/>        
            <span style="color: gray">有多个主营产品，请用、号分割开，如:保温瓶、hellokitty公仔、冰箱贴</span>
        </td>
      </tr>
      <!--{/foreach}-->
      <tr>
        <th class="paddingT15">店铺分类:</th>
        <td class="paddingT15 "></td>
      </tr>
      <!--{foreach from=$scategories item=scategory key=key}-->
      <tr>
            <td align="right">
              {$scategory.name|escape}：
            </td>
            <td>
              <p class="select">
                <!--{if $scategory.selects}-->
                    <!--{foreach from=$scategory.selects item=scate key=select_key}-->
                    <select name="sgcate_id[{$key}][]" class="sgcategory_{$key}">
                        <option value="0" a="{$scate.cate_id}">{$lang.select_pls}</option>
                        {html_options options=$scategory.child selected=$select_key}
                    </select>
                  <!-- {/foreach} -->
                <!--{else}-->
                    <select name="sgcate_id[{$key}][]" class="sgcategory_{$key}">
                        <option value="0">请选择--</option>
                        {html_options options=$scategory.child}
                    </select>
                <!--{/if}-->
                <span style="color: #999;">
                    <a href="javascript:add_sgcategory({$key});" id="add_sgcategory_{$key}" style="color:#00A0E9">新增分类</a>
                    可以选择多个分类
                </span>
              </p>
            </td>
      </tr>
      <!--{/foreach}-->
      <tr>
        <th class="paddingT15">家饰网店铺链接:</th>
        <td class="paddingT15 "><input class="infoTableInput" name="store_url" type="text" id="store_url" value="{$store.store_url}"/>        </td>
      </tr>
      <tr>
        <th class="paddingT15">展厅ID:</th>
        <td class="paddingT15 "><input class="infoTableInput" name="exh_id" type="text" id="exh_id" value="{$store.exh_id}"/>        </td>
      </tr>
      <tr id="tr_description">
          <th class="paddingT15" valign="top">企业简介:</th>
          <td class="paddingT15 "><label for="description"></label>
              <textarea name="description" id="description">{$store.description}</textarea></td>
      </tr>
      <tr id="tr_hot_image" {if !$store.hot_image} style=" display: none" {/if}>
          <th class="paddingT15">热卖图标:</th>
          <td class="paddingT15 ">
              <input type="hidden" name="hot_image" value="" />
              <img id='hot' width="40px" height="40px" src="{$site_url}/{$store.hot_image}">
          </td>
      </tr>
      <tr id="tr_feature_image" {if !$store.feature_image} style=" display: none" {/if}>
          <th class="paddingT15">特色图标:</th>
          <td class="paddingT15 ">
              <input type="hidden" name="feature_image" value="" />
              <img id='feature' width="40px" height="40px"  src="{$site_url}/{$store.feature_image}">
          </td>
      </tr>
    <tr>
        <th>商品图片上传:</th>
        <td height="100">
        <div id="divSwfuploadContainer">
            <div id="divButtonContainer">
                <span id="spanButtonPlaceholder"></span>
            </div>
            <div id="divFileProgressContainer"></div>
        </div>
        <iframe id="divComUploadContainer" style="display:none;" src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}" width="500" height="46" scrolling="no" frameborder="0">
        </iframe>
        </td>
    </tr>
    <tr>
        <th>已传图片:</th>
        <td>                
        <div class="tdare">
            <table  width="600px" cellspacing="0" class="dataTable">
                <tbody id="thumbnails">
                <!-- {foreach from=$images item=image} -->
                <tr class="tatr2" id="{$image.image_id}">
                <input type="hidden" name="image_id[]" value="{$image.image_id}" />
                <td><img src="{$site_url}/{$image.image_url}" width="100px" height="100px" /></td>
                <td><a href="javascript:insert_to('hot', '{$image.image_url}');">热卖图标</a> | <a href="javascript:insert_to('feature', '{$image.image_url}');">特色图标</a> | <a href="javascript:drop_uploadedfile({$image.image_id});">{$lang.drop}</a></td>
                </tr>
                <!-- {/foreach} -->
                </tbody>
            </table>
        </div>
        </td>
    </tr>
      <tr>
        <th></th>
        <td class="ptb20"><input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
          <input class="formbtn" type="reset" name="Reset" value="{$lang.reset}" /></td>
      </tr>
    </table>
  </form>
</div>
{include file="footer.html"}